package com.zprmb.udzt.activity;

import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.google.gson.Gson;
import com.umeng.analytics.MobclickAgent;
import com.zprmb.udzt.BaseActivity;
import com.zprmb.udzt.BbtApplication;

import com.zprmb.udzt.LoginActivity;
import com.zprmb.udzt.PayActivity;
import com.zprmb.udzt.R;
import com.zprmb.udzt.Reset_pwd_Mes;
import com.zprmb.udzt.V6ResultFinsh;
import com.zprmb.udzt.V6WebviewChild;
import com.zprmb.udzt.bean.YuePaySuccess;
import com.zprmb.udzt.http.AjaxParams;
import com.zprmb.udzt.util.Constant;
import com.zprmb.udzt.util.KeyboardEnum;
import com.zprmb.udzt.util.KeyboardEnum.ActionEnum;
import com.zprmb.udzt.util.ToastUtil;
import com.zprmb.udzt.util.VolleryUtil;
import com.zprmb.udzt.util.VolleryUtil.OnButtonListener;
import com.zprmb.udzt.view.MdStyleProgress;
import com.zprmb.udzt.view.MdStyleProgress.OnDoneCircleAnimListner;

import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * 活期投资界面
 *
 * @author shenshao
 */

public class PayZhitouActivity extends BaseActivity implements
        OnClickListener, OnButtonListener {

    private TextView pay_keyboard_one;
    private TextView pay_keyboard_two;
    private TextView pay_keyboard_three;
    private TextView pay_keyboard_four;
    private TextView pay_keyboard_five;
    private TextView pay_keyboard_sex;
    private TextView pay_keyboard_seven;
    private TextView pay_keyboard_eight;
    private TextView pay_keyboard_nine;
    private TextView pay_keyboard_zero;
    private TextView pay_keyboard_del;
    private LinearLayout rl_2;
    private TextView tv_v4_pay_zhifu;
    private ArrayList<String> mList = new ArrayList<String>();
    private StringBuffer sb = new StringBuffer();
    private StringBuffer sb_set_pass_1 = new StringBuffer();
    private StringBuffer sb_set_pass_2 = new StringBuffer();
    private TextView pay_box1;
    private TextView pay_box2;
    private TextView pay_box3;
    private TextView pay_box4;
    private String firstType = "";
    String firstamount = "";
    private TextView pay_box5;
    private TextView pay_box6;
    private TextView tv_v4_pay_paypass_status;
    private ImageView iv_v4_pay_finish;
    private int who = 2;
    private int setPass;// 设置交易密码状态 1为未设置
    private String pass1;// 设置交易密码状态下.
    private String amount, shouxu;
    double actual;
    private String type;
    private String productId;
    private TextView tv_v4_paydexterity_forget;
    private LinearLayout li_keyboard;
    private boolean isUp = true;
    Animation anim;
    private MdStyleProgress invest_progress;
//path
    String path;
    String card_no;
    String bank_name;
    String loan_id;
    String investment_Amount;

    String coupon_id;

    String coupon_type;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.v4_pay_dexterity_activity);
        BbtApplication.getInstance().addActvity(this);
        WindowManager.LayoutParams layoutparams = getWindow().getAttributes();
        layoutparams.width = layoutparams.MATCH_PARENT;
        getWindow().setAttributes(layoutparams);
        anim = AnimationUtils.loadAnimation(PayZhitouActivity.this,
                R.anim.disappear_bottom_right_in);
        Intent intent = getIntent();
        amount = intent.getStringExtra("amount");
        type = intent.getStringExtra("type");
        productId = intent.getStringExtra("productId");
        setPass = intent.getIntExtra("setPass", 0);
        shouxu = getIntent().getStringExtra("fee");
        actual = getIntent().getDoubleExtra("actual", 0);
        path=getIntent().getStringExtra("path");
        card_no=getIntent().getStringExtra("card_no");
        bank_name=getIntent().getStringExtra("bank_name");
        loan_id=getIntent().getStringExtra("loan_id");
        investment_Amount=getIntent().getStringExtra("investment_Amount");
        coupon_id=getIntent().getStringExtra("coupon_id");

        coupon_type=getIntent().getStringExtra("coupon_type");

/*

        paramMap.put("client", Source.WEB.name

                ());

*/

        initView();
    }

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
        BbtApplication.getInstance().removeActvity(this);
    }

    private void initView() {
        invest_progress = (MdStyleProgress) findViewById(R.id.invest_progress);
        li_keyboard = (LinearLayout) findViewById(R.id.li_keyboard);
        pay_keyboard_one = (TextView) findViewById(R.id.pay_keyboard_one);
        pay_keyboard_two = (TextView) findViewById(R.id.pay_keyboard_two);
        pay_keyboard_three = (TextView) findViewById(R.id.pay_keyboard_three);
        pay_keyboard_four = (TextView) findViewById(R.id.pay_keyboard_four);
        pay_keyboard_five = (TextView) findViewById(R.id.pay_keyboard_five);
        pay_keyboard_sex = (TextView) findViewById(R.id.pay_keyboard_sex);
        pay_keyboard_seven = (TextView) findViewById(R.id.pay_keyboard_seven);
        pay_keyboard_eight = (TextView) findViewById(R.id.pay_keyboard_eight);
        pay_keyboard_nine = (TextView) findViewById(R.id.pay_keyboard_nine);
        pay_keyboard_zero = (TextView) findViewById(R.id.pay_keyboard_zero);
        pay_keyboard_del = (TextView) findViewById(R.id.pay_keyboard_del);
        tv_v4_pay_paypass_status = (TextView) findViewById(R.id.tv_v4_pay_paypass_status);
        pay_keyboard_one.setOnClickListener(this);
        pay_keyboard_two.setOnClickListener(this);
        pay_keyboard_three.setOnClickListener(this);
        pay_keyboard_four.setOnClickListener(this);
        pay_keyboard_five.setOnClickListener(this);
        pay_keyboard_sex.setOnClickListener(this);
        pay_keyboard_seven.setOnClickListener(this);
        pay_keyboard_eight.setOnClickListener(this);
        pay_keyboard_nine.setOnClickListener(this);
        pay_keyboard_zero.setOnClickListener(this);
        pay_keyboard_del.setOnClickListener(this);
        rl_2 = (LinearLayout) findViewById(R.id.rl_2);
        tv_v4_pay_zhifu = (TextView) findViewById(R.id.tv_v4_pay_zhifu);
        tv_v4_pay_zhifu.setOnClickListener(this);
        pay_box1 = (TextView) findViewById(R.id.pay_box1);
        pay_box2 = (TextView) findViewById(R.id.pay_box2);
        pay_box3 = (TextView) findViewById(R.id.pay_box3);
        pay_box4 = (TextView) findViewById(R.id.pay_box4);
        pay_box5 = (TextView) findViewById(R.id.pay_box5);
        pay_box6 = (TextView) findViewById(R.id.pay_box6);
        iv_v4_pay_finish = (ImageView) findViewById(R.id.iv_v4_pay_finish);
        iv_v4_pay_finish.setOnClickListener(this);
        tv_v4_paydexterity_forget = (TextView) findViewById(R.id.tv_v4_pay_forgetpassword);
        tv_v4_paydexterity_forget.setOnClickListener(this);

        if (setPass == 1) {
            rl_2.setVisibility(View.VISIBLE);
            tv_v4_paydexterity_forget.setVisibility(View.INVISIBLE);
            tv_v4_pay_paypass_status.setText("请设置交易密码");
            who = 0;// 为了让mList不接受无效数字
            tv_v4_pay_zhifu.setText("下一步");
        } else if (setPass == 0) {
           /* if (type.equals("OUT")) {
                tv_v4_pay_zhifu.setText("转出");
            } else {
                tv_v4_pay_zhifu.setText("转入");
            }*/
        }
    }

    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_v4_pay_zhifu:
                sb.delete(0, sb.length());
                for (int i = 0; i < mList.size(); i++) {
                    sb.append(mList.get(i));
                }
                if (sb.length() < 6) {
                    ToastUtil.showCenterToast(this, "交易密码必须为6位");
                    return;
                }
                if (tv_v4_pay_zhifu.getText().toString().equals("转入")
                        || tv_v4_pay_zhifu.getText().toString().equals("转出")) {
                    tv_v4_pay_zhifu.setBackgroundResource(R.drawable.btn_unclick);
                    tv_v4_pay_zhifu.setEnabled(false);
                    invest();
                }
                break;
            case R.id.iv_v4_pay_finish:
                finish();
                break;
            case R.id.tv_v4_pay_forgetpassword:
                Intent intent = new Intent(this, Reset_pwd_Mes.class);
                startActivity(intent);
                break;
            case R.id.pay_keyboard_one:
                if (who == 1) {
                } else if (who == 2) {
                    parseActionType(KeyboardEnum.one);
                } else if (setPass == 1) {
                    setPayPass(KeyboardEnum.one);
                }
                break;
            case R.id.pay_keyboard_two:
                if (who == 1) {
                } else if (who == 2) {
                    parseActionType(KeyboardEnum.two);
                } else if (setPass == 1) {
                    setPayPass(KeyboardEnum.two);
                }
                break;
            case R.id.pay_keyboard_three:
                if (who == 1) {
                } else if (who == 2) {
                    parseActionType(KeyboardEnum.three);
                } else if (setPass == 1) {
                    setPayPass(KeyboardEnum.three);
                }
                break;
            case R.id.pay_keyboard_four:
                if (who == 1) {
                } else if (who == 2) {
                    parseActionType(KeyboardEnum.four);
                } else if (setPass == 1) {
                    setPayPass(KeyboardEnum.four);
                }
                break;
            case R.id.pay_keyboard_five:
                if (who == 1) {
                } else if (who == 2) {
                    parseActionType(KeyboardEnum.five);
                } else if (setPass == 1) {
                    setPayPass(KeyboardEnum.five);
                }
                break;
            case R.id.pay_keyboard_sex:
                if (who == 1) {
                } else if (who == 2) {
                    parseActionType(KeyboardEnum.sex);
                } else if (setPass == 1) {
                    setPayPass(KeyboardEnum.sex);
                }
                break;
            case R.id.pay_keyboard_seven:
                if (who == 1) {
                } else if (who == 2) {
                    parseActionType(KeyboardEnum.seven);
                } else if (setPass == 1) {
                    setPayPass(KeyboardEnum.seven);
                }
                break;
            case R.id.pay_keyboard_eight:
                if (who == 1) {
                } else if (who == 2) {
                    parseActionType(KeyboardEnum.eight);
                } else if (setPass == 1) {
                    setPayPass(KeyboardEnum.eight);
                }
                break;
            case R.id.pay_keyboard_nine:
                if (who == 1) {
                } else if (who == 2) {
                    parseActionType(KeyboardEnum.nine);
                } else if (setPass == 1) {
                    setPayPass(KeyboardEnum.nine);
                }
                break;
            case R.id.pay_keyboard_zero:
                if (who == 1) {
                } else if (who == 2) {
                    parseActionType(KeyboardEnum.zero);
                } else if (setPass == 1) {
                    setPayPass(KeyboardEnum.zero);
                }
                break;
            case R.id.pay_keyboard_del:
                if (who == 1) {
                } else if (who == 2) {
                    parseActionType(KeyboardEnum.del);
                } else if (setPass == 1) {
                    setPayPass(KeyboardEnum.del);
                }
                break;
        }
    }

    /**
     * 设置交易密码
     *
     * @param type
     */
    private void setPayPass(KeyboardEnum type) {
        if (type.getType() == ActionEnum.add) {
            if (sb_set_pass_1.length() < 6) {
                mList.add(type.getValue());
                sb_set_pass_1.append(type.getValue());
                updateUi();
                if (mList.size() == 6) {
                    sb_set_pass_1.delete(0, sb_set_pass_1.length());
                    for (int i = 0; i < mList.size(); i++) {
                        sb_set_pass_1.append(mList.get(i));
                    }
                    if (tv_v4_pay_paypass_status.getText().toString().equals("请设置交易密码")) {
                        tv_v4_pay_paypass_status.setText("请确认交易密码");
                        pass1 = sb_set_pass_1.toString();
                        sb_set_pass_1.delete(0, sb_set_pass_1.length());
                        mList.clear();
                        updateUi();
                        li_keyboard.setAnimation(anim);
                    } else if (tv_v4_pay_paypass_status.getText().toString().equals("请确认交易密码")) {
                        if (pass1.equals(sb_set_pass_1.toString())) {
                            initSetPass();
//							ToastUtil.showCenterToast(this, "设置密码");
                        } else {
                            ToastUtil.showCenterToast(this, "两次输入的交易密码不一致，请重新输入");
                        }
                    }


                }
            }
        } else if (type.getType() == ActionEnum.delete) {
            if (sb_set_pass_1.length() > 0) {
                mList.remove(mList.get(mList.size() - 1));
                sb_set_pass_1.delete(sb_set_pass_1.length() - 1,
                        sb_set_pass_1.length());
                updateUi();
            }
        }
    }

    private void parseActionType(KeyboardEnum type) {
        if (type.getType() == ActionEnum.add) {
            if (mList.size() < 6) {
                mList.add(type.getValue());
                updateUi();
                if (mList.size() == 6) {
                    sb.delete(0, sb.length());
                    for (int i = 0; i < mList.size(); i++) {
                        sb.append(mList.get(i));
                    }
                    li_keyboard.setVisibility(View.GONE);
                    invest_progress.setVisibility(View.VISIBLE);
//					if (tv_v4_pay_paypass_status.getText().toString().equals("请输入支付密码")) {
                    invest();
//					} else if (tv_v4_pay_paypass_status.getText().toString().equals("请设置交易密码")) {
//						tv_v4_pay_paypass_status.setText("请确认交易秘密");
//						pass1 = sb_set_pass_1.toString();
//						sb_set_pass_1.delete(0, sb_set_pass_1.length());
//						mList.clear();
//						updateUi();
//						if (pass1.equals(sb_set_pass_1.toString())) {
////							initSetPass();
//							ToastUtil.showCenterToast(this, "设置密码");
//						} else {
//							ToastUtil.showCenterToast(this, "两次输入的交易密码不一致，请重新输入");
//						}
//				}
                }
            }
        } else if (type.getType() == ActionEnum.delete) {
            if (mList.size() > 0) {
                mList.remove(mList.get(mList.size() - 1));
                updateUi();
            }
        }
    }

    private void updateUi() {
        if (mList.size() == 0) {
            pay_box1.setText("");
            pay_box2.setText("");
            pay_box3.setText("");
            pay_box4.setText("");
            pay_box5.setText("");
            pay_box6.setText("");
        } else if (mList.size() == 1) {
            pay_box1.setText(mList.get(0));
            pay_box2.setText("");
            pay_box3.setText("");
            pay_box4.setText("");
            pay_box5.setText("");
            pay_box6.setText("");
        } else if (mList.size() == 2) {
            pay_box1.setText(mList.get(0));
            pay_box2.setText(mList.get(1));
            pay_box3.setText("");
            pay_box4.setText("");
            pay_box5.setText("");
            pay_box6.setText("");
        } else if (mList.size() == 3) {
            pay_box1.setText(mList.get(0));
            pay_box2.setText(mList.get(1));
            pay_box3.setText(mList.get(2));
            pay_box4.setText("");
            pay_box5.setText("");
            pay_box6.setText("");
        } else if (mList.size() == 4) {
            pay_box1.setText(mList.get(0));
            pay_box2.setText(mList.get(1));
            pay_box3.setText(mList.get(2));
            pay_box4.setText(mList.get(3));
            pay_box5.setText("");
            pay_box6.setText("");
        } else if (mList.size() == 5) {
            pay_box1.setText(mList.get(0));
            pay_box2.setText(mList.get(1));
            pay_box3.setText(mList.get(2));
            pay_box4.setText(mList.get(3));
            pay_box5.setText(mList.get(4));
            pay_box6.setText("");
        } else if (mList.size() == 6) {
            pay_box1.setText(mList.get(0));
            pay_box2.setText(mList.get(1));
            pay_box3.setText(mList.get(2));
            pay_box4.setText(mList.get(3));
            pay_box5.setText(mList.get(4));
            pay_box6.setText(mList.get(5));
        }
    }
    private final String ACTION_NAME = "智投宝结束";
    /**
     * 转入转出
     */
    private void invest() {

//            http://192.168.0.103:8080/hpay/v3/h5recharge?amount=28887179.1&loan_id=C1D738CD-17EA-11E8-A093-5254003C8227&bank_name=
            AjaxParams params = new AjaxParams();
           /* if (type.equals("OUT")) {
                params.put("amount", amount);
                params.put("payPass", sb.toString());
            } else {
                params.put("amount", amount);
                params.put("payPass", sb.toString());
                params.put("productType", "CURRENT_DEPOSIT");
                params.put("productId", productId);
                params.put("payType", "PWD");

            }*/

          /*  hpay/v3/h5recharge
            String amount 充值金额
            String path 充值类型
            String card_no 银行卡号
            bank_name 银行编号
            String token
            String loan_id 产品ID
            String type 产品类型
            String investment_Amount 投资金额
            String coupon_id 道具id
            String coupon_type 道具类型*/





        params.put("amount", amount);
        params.put("path", path);
        params.put("card_no", card_no);
        params.put("bank_name",bank_name);

        params.put("token", getToken());
        params.put("loan_id", loan_id);
        params.put("type", type);
        params.put("investment_Amount", "100");

        params.put("coupon_id", "");
        params.put("coupon_type", "PWD");
        params.put("client", "android");







       /*    params.put("amount",amount);
            params.put("path","1");
            params.put("card_no",card_no);
            params.put("bank_name",bank_name);
            params.put("token",getToken());
            params.put("loan_id",productId);
            params.put("type","IN");
            params.put("investment_Amount","100");
            params.put("coupon_id","");
            params.put("coupon_type","");
            params.put("client", "android");*/
           /* amount = intent.getStringExtra("amount");
            type = intent.getStringExtra("type");
            productId = intent.getStringExtra("productId");
            setPass = intent.getIntExtra("setPass", 0);
            shouxu = getIntent().getStringExtra("fee");
            actual = getIntent().getDoubleExtra("actual", 0);
            path=getIntent().getStringExtra("path");
            card_no=getIntent().getStringExtra("card_no");
            bank_name=getIntent().getStringExtra("bank_name");
            loan_id=getIntent().getStringExtra("loan_id");
            investment_Amount=getIntent().getStringExtra("investment_Amount");
            coupon_id=getIntent().getStringExtra("coupon_id");

            coupon_type=getIntent().getStringExtra("coupon_type");



            paramMap.put("client", Source.WEB.name*/
            VolleryUtil vollery = new VolleryUtil() {

                @Override
                public void onUpDate(final JSONObject jsonObject) {
                    // TODO Auto-generated method stub
                    Log.e("转出", jsonObject.toString());
                    isUp = true;
                    if (jsonObject.optInt("success") == 1) {
                        invest_progress.setStatus(MdStyleProgress.Status.LoadSuccess);
                        invest_progress.startAnima();
//                        ToastUtil.showCenterToast(
//                                PayZhitouActivity.this,
//                                jsonObject.optString("comment"));
                        tv_v4_pay_zhifu.setBackgroundResource(R.drawable.my_button);
                        tv_v4_pay_zhifu.setEnabled(true);
                        final JSONObject json1 = jsonObject.optJSONObject("data");
                        if (json1.optBoolean("firstFlag")) {
                            firstType = "1";
                        } else {
                            firstType = "0";
                        }
                        invest_progress.addCircleAnimatorEndListner(new OnDoneCircleAnimListner() {

                            @Override
                            public void onCircleDone() {
                                // TODO Auto-generated method stub
                                if (type.equals("IN")) {

                                   /* firstamount = json1.optString("ExperienceAmount");
                                    Intent intent = new Intent(PayZhitouActivity.this, V6WebviewChild.class);
                                    intent.putExtra("submit", json1.optString("expectDueDateDesc"));
                                    intent.putExtra("active_url", Constant.URL + "h5/currentDetail?isInvest=1&flagFresh=" + false + "&isFirstInvest=" + firstType + "&productType=" + "dexterity" + "&amount=" + amount + "&action=1&app=true&token=");
                                    intent.putExtra("url", Constant.URL + "h5/currentDetail?&app=true&token=");
                                    intent.putExtra("active", 1);
                                    intent.putExtra("title", "智投宝");
                                    intent.putExtra("dexterity", 1);
                                    intent.putExtra("amount", amount);
                                    intent.putExtra("firstamount", firstamount);
                                    intent.putExtra("firstType", firstType);
                                    intent.putExtra("rate", json1.optString("count_rate_date"));
                                    startActivity(intent);*/
                                    YuePaySuccess yuePaySuccess = new YuePaySuccess();
                                    Gson gson = new Gson();
                                    yuePaySuccess = gson.fromJson(jsonObject.toString(), YuePaySuccess.class);


                                    Intent intent = new Intent(PayZhitouActivity.this, SuccessZhiTouYueActivity.class);

                                    intent.putExtra("active_url", yuePaySuccess.getData().getExpUrl());

                                    intent.putExtra("title", getIntent().getStringExtra("title"));

                                    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//收益到账
                                    Long time = new Long(yuePaySuccess.getData().getExpectDueDate());
                                    //起息日期
                                    Long time2 = new Long(yuePaySuccess.getData().getCount_rate_date());
                                    String d = format.format(time);
                                    String e = format.format(time2);
                                    intent.putExtra("qixi", e);

                                    intent.putExtra("jieshu", d);
                                    intent.putExtra("investmoney", yuePaySuccess.getData().getAmount());

                                    startActivity(intent);
                                    Intent mIntent = new Intent(ACTION_NAME);
                                    mIntent.putExtra("yaner", "发送广播，相当于在这里传送数据");
                                    //发送广播
                                    sendBroadcast(mIntent);

                                    finish();
                                    UmengDate();
//									Intent mIntent = new Intent();
//					                mIntent.setAction("exit");
//					                sendBroadcast(mIntent);
                                } else {
                               /*     Intent intent = new Intent(PayZhitouActivity.this, DexterityoutSuccess.class);
                                    intent.putExtra("amount", amount);
                                    intent.putExtra("huo", 0);
                                    intent.putExtra("fee", shouxu);
                                    intent.putExtra("actual", actual);
                                    intent.putExtra("date", json1.optString("fundsRecordedDate"));
                                    startActivity(intent);*/
                                }
                                PayZhitouActivity.this.finish();
                            }
                        });


                    } else {
                        invest_progress.setStatus(MdStyleProgress.Status.LoadFail);
                        invest_progress.failAnima();
                        invest_progress.addCircleAnimatorEndListner(new OnDoneCircleAnimListner() {

                            @Override
                            public void onCircleDone() {
                                // TODO Auto-generated method stub
                                finish();
                            }
                        });
                        if (jsonObject.optString("comment").equals(
                                "please login")) {
                            if (jsonObject.optString("comment").equals("please login")) {
                                Intent intent = new Intent(PayZhitouActivity.this,
                                        LoginActivity.class);
                                intent.putExtra("close", 1);
                                startActivity(intent);
                            }
                            tv_v4_pay_zhifu.setBackgroundResource(R.drawable.my_button);
                            tv_v4_pay_zhifu.setEnabled(true);
                        } else {
                            tv_v4_pay_zhifu.setBackgroundResource(R.drawable.my_button);
                            tv_v4_pay_zhifu.setEnabled(true);
                            ToastUtil.showCenterToast(
                                    PayZhitouActivity.this,
                                    jsonObject.optString("comment"));
                        }
                    }
                }

                @Override
                public void onError() {
                    // TODO Auto-generated method stub
                    invest_progress.setStatus(MdStyleProgress.Status.LoadFail);
                    invest_progress.failAnima();
                    invest_progress.addCircleAnimatorEndListner(new OnDoneCircleAnimListner() {

                        @Override
                        public void onCircleDone() {
                            // TODO Auto-generated method stub
                            finish();
                        }
                    });
                    isUp = true;
                    tv_v4_pay_zhifu.setBackgroundResource(R.drawable.my_button);
                    tv_v4_pay_zhifu.setEnabled(true);
                    Intent intent = new Intent(PayZhitouActivity.this, V6ResultFinsh.class);
                    if (type.equals("OUT")) {
                        intent.putExtra("title", "转出结果");
                        intent.putExtra("description2", "确认转出结果！若转出失败请重新操作");
                    } else {
                        intent.putExtra("title", "转入结果");
                        intent.putExtra("description2", "确认转入结果！若转入失败请重新操作");
                    }
                    intent.putExtra("description1", "您好，系统正在处理中，\n请3~5分钟之后前往 “我的账户-智投宝”");
                    intent.putExtra("button", "我的智投宝");
                    startActivity(intent);
                    PayZhitouActivity.this.finish();
                }
            };
            vollery.OnButtonListener(this);
            vollery.setShow(true);
            vollery.setHeaders("token", getToken());
            vollery.setHeaders("client", "android");
            vollery.setRequestMethod(1);
          /*  amount = intent.getStringExtra("amount");
            type = intent.getStringExtra("type");
            productId = intent.getStringExtra("productId");
            setPass = intent.getIntExtra("setPass", 0);
            shouxu = getIntent().getStringExtra("fee");
            actual = getIntent().getDoubleExtra("actual", 0);
            path=getIntent().getStringExtra("path");
            card_no=getIntent().getStringExtra("card_no");
            bank_name=getIntent().getStringExtra("bank_name");
            loan_id=getIntent().getStringExtra("loan_id");
            investment_Amount=getIntent().getStringExtra("investment_Amount");
            coupon_id=getIntent().getStringExtra("coupon_id");

            coupon_type=getIntent().getStringExtra("coupon_type");



        paramMap.put("client", Source.WEB.name
8
http://192.168.0.103:8080/hpay/v3/h5recharge?amount=28887179.1&loan_id=C1D738CD-17EA-11E8-A093-5254003C8227&bank_name=
                ());
*/
          /*  if (type.equals("OUT")) {
                vollery.execute(this, Constant.URL
                                + "api/v2/claim/fund/current/redemption?",
                        params.toString());
//				Log.e("转出", "转出请求了volley类");
            } else {
                vollery.execute(this, Constant.URL
                        + "api/v2/claim/fund/invest?", params.toString());
            }*/
            vollery.execute(this, Constant.URL
                    + "hpay/v3/h5recharge?", params.toString());


    }

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            finish();
            overridePendingTransition(R.anim.slide_in_from_bottom,
                    R.anim.slide_out_to_bottom);
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    /**
     * 设置交易密码
     */
    private void initSetPass() {
        AjaxParams params = new AjaxParams();
        params.put("payPass", sb_set_pass_1.toString());
        VolleryUtil vollery = new VolleryUtil() {

            @Override
            public void onUpDate(JSONObject jsonObject) {
                // TODO Auto-generated method stub
                if (jsonObject.optInt("success") == 1) {
                    tv_v4_pay_paypass_status.setText("输入交易密码");
                    mList.clear();
                    updateUi();
                    if (type.equals("OUT")) {
                        tv_v4_pay_zhifu.setText("转出");
                    } else if (type.equals("IN")) {
                        tv_v4_pay_zhifu.setText("转入");
                    }
                    tv_v4_paydexterity_forget.setVisibility(View.VISIBLE);
                    ToastUtil.showCenterToast(PayZhitouActivity.this,
                            jsonObject.optString("comment"));
                    who = 2;
                } else {
                    ToastUtil.showCenterToast(PayZhitouActivity.this,
                            jsonObject.optString("comment"));
                }
            }

            @Override
            public void onError() {
                // TODO Auto-generated method stub

            }
        };
        vollery.setHeaders("token", getToken());
        vollery.setHeaders("client", "android");
        vollery.setShow(true);
        vollery.execute(this, Constant.URL + "api/v2/setPayPass?",
                params.toString());
    }

    private void UmengDate() {
        try {
            ApplicationInfo appInfo = this.getPackageManager()
                    .getApplicationInfo(getPackageName(),
                            PackageManager.GET_META_DATA);
            String msg = appInfo.metaData.getString("UMENG_CHANNEL");
            Map<String, String> m = new HashMap<String, String>();
            m.put(msg, msg);
            MobclickAgent.onEventValue(this, "ling_in", m,
                    Integer.valueOf(amount));
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void change() {
        // TODO Auto-generated method stub
        tv_v4_pay_zhifu.setBackgroundResource(R.drawable.my_button);
        tv_v4_pay_zhifu.setEnabled(true);
    }

}
